<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>登录中，请稍候...</title>
    　<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  </head>
  <body>
    <div id="app">
      登录中，请稍候...
    </div>
    <!-- built files will be auto injected -->
  </body>
<script>
  //先获取当前登录用户

  $.ajax({
      url:'/api/base/user/current',
      success:function (res) {
          console.log('success')
          console.log(res)
          alert('userinfosuccess')
          // 成功则跳转
          window.location.href = 'http://feihua666.ngrok.xiaomiqiu.cn/api/wxlogintestsucess.html'
      },
      error:function (res) {
          console.log('error')
          console.log(res)

          alert('userinfoerror')
          // 如果获取当前登录用户信息失败，表明没有登录，尝试获取用户信息
          //尝试登录
          $.ajax({
              url:'/api/login',
              method:'POST',
              data:{loginType:'WX_PLATFORM',type:'yangwei'},
              success:function (res) {
                  alert('loginsuccess')
                  // 成功则跳转
                  window.location.href = 'http://feihua666.ngrok.xiaomiqiu.cn/api/wxlogintestsucess.html'
              },
              error:function (res) {
                  alert('loginerror')
                  var userinfourl = 'http://feihua666.ngrok.xiaomiqiu.cn/api/publicplatform/getAuthUserInfo/yangwei?redirectUrl=http://feihua666.ngrok.xiaomiqiu.cn/api/wxlogintest.html'

                  window.location.href = '/api/publicplatform/redirectToAuthAuthorizePage/yangwei?redirectUrl=' + encodeURIComponent(userinfourl)
              }
          })

      }

  })
</script>
</html>
